<?php include "header.php";?>
	<div id="all">
		<?php
			if($lang == 0){
				$sqlMenu = "Select id, vi_name as name, parent_id from tblMenu where id =" .$menuID; 
			}else{
				$sqlMenu = "Select id, en_name as name, parent_id from tblMenu where id =" .$menuID; 
			}
			
			$rsMenu = mysql_query($sqlMenu) or die(mysql_error);
			$menu = mysql_fetch_object($rsMenu);

			if($menu->parent_id != 0){
				
				if($lang==0){
					$sqlParentMenu="select id, vi_name as name, parent_id from tblMenu where id=" .$menu->parent_id;
				}else{
					$sqlParentMenu="select id, en_name as name, parent_id from tblMenu where id=" .$menu->parent_id;
				}
				
				$rsParentMenu = mysql_query($sqlParentMenu) or die(mysql_error);
				$parentMenu = mysql_fetch_object($rsParentMenu);
				
			}
			if($lang == 0){
				$sqlChildMenus = "Select id, vi_name as name, url from tblMenu where parent_id =" .$menuID; 
			}else{
				$sqlChildMenus = "Select id, en_name as name, url from tblMenu where parent_id =" .$menuID; 
			}
			$rsChildMenus = mysql_query($sqlChildMenus) or die(mysql_error);
			
		?>
		<div id="main">
			<div id="m-left">
				<div class="sidebar">
					<div class="title">
						
						<?php
						if($menu->parent_id != 0){ 
							echo $parentMenu->name;
						}else{
							echo $menu->name;
						}
						?>
					</div>
					<div class="container">
						<ul>
							<?php
								$arrChildMenu = array();
								while($childMenu = mysql_fetch_object($rsChildMenus)) {
									$arrChildMenu[] = $childMenu;
								}
								if($menu->parent_id !=0){
									if($lang == 0){
										$sqlChildMenus1 = "Select id, vi_name as name, url from tblMenu where parent_id =" .$parentMenu->id; 
									}else{
										$sqlChildMenus1 = "Select id, en_name as name, url from tblMenu where parent_id =" .$parentMenu->id; 
									}
									
									$rsChildMenus1 = mysql_query($sqlChildMenus1) or die(mysql_error);
									while($childMenu1 = mysql_fetch_object($rsChildMenus1)) {
										echo "<li><a href='".(($childMenu1->url =="")? (ROOT_PATH."/m/".$childMenu1->id) : ROOT_PATH.$childMenu1->url)."'>".$childMenu1->name."</a></li>";
									}
								}else{
									foreach($arrChildMenu as $childMenu){
										echo "<li><a href='".(($childMenu->url =="")? (ROOT_PATH."/m/".$childMenu->id) : ROOT_PATH.$childMenu->url)."'>".$childMenu->name."</a></li>";
									}
								}
								
							?>
							
						</ul>
					</div>
				</div>
			</div>
			<div id="m-mid">
				<div class="title">
					<?php if($lang !=0){
						echo "Structure of ".$menu->name." menu";
					}else{
						echo "Cấu trúc của menu ".$menu->name;
					}?>
				</div>
				<div class="content">
						<ul>
						
							<?php
								foreach($arrChildMenu as $childMenu){
									//hiển thị menu con lên
									echo "<li><a href='".(($childMenu->url =="")? (ROOT_PATH."/m/".$childMenu->id) : ROOT_PATH .$childMenu->url)."'>".$childMenu->name."</a>";
									if($lang==0){
										$sqlChildMenu1 = "select id, vi_name as name, url from tblmenu where parent_id = ".$childMenu->id;
									}else{
										$sqlChildMenu1 = "select id, en_name as name, url from tblmenu where parent_id = ".$childMenu->id;
									}
									$rsChildMenus1 = mysql_query($sqlChildMenu1) or die(mysql_error());
									if(mysql_num_rows($rsChildMenus1) > 0){
										echo "<ul>";
										while($childMenu1 = mysql_fetch_object($rsChildMenus1)){
											echo "<li><a href='".(($childMenu1->url =="")? (ROOT_PATH."/m/".$childMenu1->id) : ROOT_PATH .$childMenu1->url)."'>".$childMenu1->name."</a><li>";
											
										}
										echo "</ul>";
									}
									echo "</li>";
								}
							?> 
							
						</ul>
						
					
				</div>
			</div>
			<div id="m-right">
			
				<div class="sidebar">
					<div class="title">
						<?php if($lang == 0){
							echo "Tin tức mới nhất";
						}else{
							echo "Newest news";
						}?>
					</div>
					<div class="container">
						<ul>
							<?php
								if($lang == 0){
									$sqlNews ="Select id,vi_title as title from tblarticle order by created_date desc Limit 5";
								}else{
									$sqlNews ="Select id,en_title as title from tblarticle order by created_date desc limit 5";
								}
								$rsNews = mysql_query($sqlNews) or die(mysql_error());
								while($news = mysql_fetch_object($rsNews)){
									echo "<li><a href='".ROOT_PATH."/view/".$news->id."'>".$news->title."</a></li>";
								}
								
							?>
							
						</ul>
					</div>
				</div>
			</div>
			<div class="clear-fix"></div>
		</div><!--  end of main -->
		<div id="footer">
			<div id="f-menu">
				<ul>
					<?php foreach($arrRootMenus as $rootMenu){
						if($lang ==0){
							echo "<li><a href='".ROOT_PATH.(($rootMenu->url=="")? "/m/".$rootMenu->id: ROOT_PATH. $rootMenu->url)."'>".$rootMenu->vi_name."</a></li>";
						}else{
							echo "<li><a href='".ROOT_PATH.(($rootMenu->url=="")? "/m/".$rootMenu->id: ROOT_PATH . $rootMenu->url)."'>".$rootMenu->en_name."</a></li>";
						}
					}?>
				</ul>
			</div>
			<div id="copyright">
				Bản quyền thuộc về khoa quốc tế đại học Thái Nguyên<br/>
				Copyright &copy; 2011 <a href="http://idgit.com.vn">Idea Development Group</a>
			</div>
			
		</div>
	</div>
</body>
</html>